package com.uml.umlwork.vo.clazz;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.uml.umlwork.entity.Class;
import io.swagger.annotations.ApiModelProperty;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.Optional;

/**
 * @author Siki
 * @date 2021/1/7
 */

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class ClassVO {

    @ApiModelProperty("id")
    private Integer id;

    @ApiModelProperty("是否发布培训信息")
    private Boolean isAnnounce;

    @ApiModelProperty("开班时间")
    private LocalDateTime startDate;

    @ApiModelProperty("学费")
    private String tuition;

    @ApiModelProperty("课程ID")
    private Integer courseId;

    @ApiModelProperty("培训师ID")
    private String teacherId;

    public ClassVO(Class classes){
        Optional.ofNullable(classes).ifPresent(clazz->{
            this.id = clazz.getId();
            this.startDate = clazz.getStartDate();
            this.isAnnounce = clazz.getIsAnnounce();
            this.tuition = clazz.getTuition();
            this.courseId = clazz.getCourseId();
            this.teacherId = clazz.getTeacherId();
        });
    }
}
